using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using KNCApp.GUI.TreeGrid;

namespace KNCApp.GUI.Browser
{
    public partial class PilotsBrowser : CmnBrowser
    {
        #region CTOR
        public PilotsBrowser()
        {
            InitializeComponent();



        }
        #endregion

        #region OVERRIDE

        override protected void GetSearchResult(Business.Models.SearchCriteria sc)
        {
            List<Business.Models.Pilot> pilots = KNCApp.DataSource.DataSourceProvider.GetDS().SelectPilots(sc);
            foreach (Business.Models.Pilot p in pilots)
            {
                AddItem(p, null);
            }
        }

        override protected TreeGridNode AddItem(Business.Models.AbstractObj item, TreeGridNode parentNode)
        {
            TreeGridNode node = null;
            if(item is Business.Models.Pilot)
            {
                Business.Models.Pilot p = item as Business.Models.Pilot;

                node = dataGridView.Nodes.Add(p.FirstName, p.LastName, p.DoB.ToShortDateString());
                node.Tag = p;
            }
            return node;
        }
        #endregion

    }
}